using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls;

namespace ARF.Web.Controls
{
    public class BaseForm : TemplateBasedControl
    {
        protected Control FindTemplateControl(string controlID)
        {
            return TemplateContainer.FindControl(controlID);
        }

        protected TextBox GetTextBox(string controlID)
        {
            return ((TextBox)FindTemplateControl(controlID));
        }

        protected DropDownList GetDropList(string controlID)
        {
            return ((DropDownList)FindTemplateControl(controlID));
        }

        protected virtual void ShowPanel(string panelID, bool visible)
        {
            Control cPanel = FindTemplateControl(panelID);
            if (cPanel != null)
            {
                Panel p = cPanel as Panel;
                p.Visible = visible;
            }
        }

        protected virtual void AddButtonHandler(string id, EventHandler handler)
        {
            Control cButton = FindTemplateControl(id);
            if (cButton is Button)
            {
                Button okButton = cButton as Button;
                okButton.Click += handler;
            }
            else
                Log.Trace(id + " Button not found. Please ensure a button exists which has an ID of " + id);
        }

    }
}
